#include "stm32f10x.h"
#include "stdint.h"
#include "fonts.h"

#define Bank1_LCD_D    ((uint32_t)0x60020000)    
#define Bank1_LCD_C    ((uint32_t)0x60000000)   

#define LCD_BackLightOn() GPIO_SetBits(GPIOD, GPIO_Pin_13) 

#define LCD_COLOR_WHITE          0xFFFF
#define LCD_COLOR_BLACK          0x0000
#define LCD_COLOR_GREY           0xF7DE
#define LCD_COLOR_BLUE           0x001F
#define LCD_COLOR_BLUE2          0x051F
#define LCD_COLOR_BLUE3          0xF6FF
#define LCD_COLOR_RED            0xF800
#define LCD_COLOR_MAGENTA        0xF81F
#define LCD_COLOR_GREEN          0x07E0
#define LCD_COLOR_GREEN2         0xFF26
#define LCD_COLOR_CYAN           0x7FFF
#define LCD_COLOR_YELLOW         0xFFE0

#define LCD_DEFAULT_FONT         Font16x24

void ILI9325_Init(void);

void ILI9325_WriteIR(unsigned int index);
void ILI9325_SetRegister(unsigned int index,unsigned int val);
void ILI9325_WriteWDR(unsigned int val);
unsigned int ILI9325_ReadRDR(void);

#define ILI9325_GRAMOperation() ILI9325_WriteIR(0x22)
#define ILI9325_WritePixel(x) ILI9325_WriteWDR(x)

#define ILI9325_VerticalScreen() ILI9325_SetRegister(0x0003,0x1030)
#define ILI9325_HorizontalScreen() ILI9325_SetRegister(0x0003,0x1038)
#define ILI9325_ZoomInByTwo() ILI9325_SetRegister(0x0004, 0x0001)
#define ILI9325_ZoomInByFour() ILI9325_SetRegister(0x0004, 0x0003)

void ILI9325_DrawWindowArea(unsigned int startX,unsigned int startY,
                                                                                                                unsigned int width,unsigned int height,
                                                                                                          unsigned int pixels[]);
void ILI9325_FillWindowArea(unsigned int startX,unsigned int startY,
                            unsigned int width,unsigned int height,unsigned int pixel);
void ILI9325_SetCursorPos(unsigned int x ,unsigned int y);
void ILI9325_SetFont(sFONT *fonts);
void ILI9325_DrawChar(uint8_t Xpos, uint16_t Ypos, const uint16_t *c);
void ILI9325_DisplayChar(uint8_t Line, uint16_t Column, uint8_t Ascii);
void ILI9325_DisplayStringLine(uint8_t Line, char *ptr);
void LCD_WriteBMP(uint16_t Xpos, uint16_t Ypos, char *fileName, uint8_t direction);
void ILI9325_DrawMonoPict(const char *Pict);
void ILI9325_DrowProgessBar(uint16_t startX,uint16_t startY, uint16_t width,uint16_t height,uint16_t color);
void ILI9325_DrowLine(uint16_t x0,uint16_t y0, uint16_t x1,uint16_t y1,uint16_t color);
void ILI9325_Clear();
void ILI9325_SetBackColor(uint16_t color);
void ILI9325_DrowPoint(uint16_t x, uint16_t y, uint16_t color);
void ILI9325_DrowBigPoint(uint16_t x, uint16_t y, uint16_t color);